package com.ruoyi.web.controller.saas;

import com.bonuo.saas.domain.DeviceMaintenance;
import com.bonuo.saas.service.DeviceMaintenanceService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "设备维护管理")
@RestController
@RequestMapping("/saas/deviceMaintenance")
public class DeviceMaintenanceController extends BaseController {

    @Autowired
    private DeviceMaintenanceService deviceMaintenanceService;

    @ApiOperation(value = "查询设备维护列表",httpMethod = "GET")
    @GetMapping("/list")
    public AjaxResult list(DeviceMaintenance deviceMaintenance, Integer pageNum, Integer pageSize){
        if(pageNum != null && pageSize != null){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<DeviceMaintenance> list = deviceMaintenanceService.selectDeviceMaintenanceList(deviceMaintenance);
        return success(new PageInfo<>(list));
    }

    @ApiOperation(value = "添加设备维护",httpMethod = "POST")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DeviceMaintenance deviceMaintenance){
        return toAjax(deviceMaintenanceService.insertDeviceMaintenance(deviceMaintenance));
    }

    @ApiOperation(value = "修改设备维护",httpMethod = "PUT")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody DeviceMaintenance deviceMaintenance){
        return toAjax(deviceMaintenanceService.updateDeviceMaintenance(deviceMaintenance));
    }

    @ApiOperation(value = "删除设备维护",httpMethod = "DELETE")
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable("id") Integer id){
        return toAjax(deviceMaintenanceService.deleteDeviceMaintenanceById(id));
    }


}
